<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="pub/top_list2.jsp"%>
<%-- <% String p=request.getParameter("p");
if(p!=null&&!p.isEmpty()) {
	
	if(p.equals("0")){
		%>  
		<script type='text/javascript'>alert('该账户已被注册，请重新注册');
		</script>
	
	<%
	}else{%>  
	<script type='text/javascript'>alert('注册成功');
	</script>

<%
	}	
	}
%> --%>
<style>
#ajax{
	width: 94%;
    margin: 5% 3%;
    display: block;
    padding: 4% 0;
    background-color: #db3752;
    color: #fff;
    text-align: center;
    font-size: 1.7em;
    border-radius: 0.3em;
    border: none;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
	$("#ajax").mousedown(function(){
		ajax();
	});
});
function ajax(){
	var userid=$("#userid").val();
	var password=$("#password").val();
	$.ajax({
		type:"post",
		url:"signAjax.jsp",
		dataType:"text",
		async : false,
		cache : false,
		data:"userid="+userid+"&password="+password,
		success:function(d){
			if(d=="fail"){
				alert("该账号已被注册，请重新注册");
				qingkong();
			}else if(d=="ok"){
				var con=confirm("您已注册成功，是否登录？");
				if(con==true)
					window.location.href="login.jsp";
				else 
					window.location.href="index.jsp";
			}else{
				alert("注册失败");
				qingkong();
			}
			
		},
		error:function(e){
			console.log(e)
		}
	});
}

function qingkong(){
	document.getElementById("userid").value="";	
	document.getElementById("password").value=""; 
	document.getElementById("password1").value=""; 
}
</script>
<script language="javascript">
	function isValid(form) {
		if (form.userid.value == "") {
			alert("用户名不能为空");
			return false;
		}
		if (form.password.value != form.password1.value) {
			alert("两次输入的密码不同！");
			return false;
		} else if (form.password.value == "") {
			alert("用户密码不能为空！");
			return false;
		} else
			return true;
	}
</script>

<body>
	<header class="top-header">
		<a class="text texta" href="index.jsp">取消</a>
		<h3>注册</h3>
		<a class="text" href="login.jsp">登录</a>
	</header>

	<div class="login">
		<form action="" method="post"
			onSubmit="return isValid(this);">
			<ul>
				<li><img src="images/login.png" /> <label>账号</label> <input
					type="text" name="userid" id="userid" placeholder="请输入账号" /></li>
				<li><img src="images/password.png" /> <label>密码</label> <input
					type="password" name="password" id="password" placeholder="请输入密码" /></li>
				<li><img src="images/password.png" /> <label>确认密码</label> <input
					type="password" name="password1" id="password1" placeholder="请再次输入密码" style=""/></li>
			</ul>
			<input type="button" id="ajax" value="注册" />
		</form>
	</div>

</body>
</html>
